// dask
// import init from '@feidao/web/framework/browser/d/component';
// dask + nools
import init from '@feidao/web/framework/browser/dn/component';
// dask + nools + statemachine
// import init from '@feidao/web/framework/browser/dns/component';
// dask + statemachine
// import init from '@feidao/web/framework/browser/ds/component';

import s from './s';
import { id, spaceid, systemid, refsystemid } from './config';

////////////////////////////////////////////////////////////////////////////////
// import actions
import a001 from './a001';
import a002 from './a002';
import a003 from './a003';
import a004 from './a004';
import a005 from './a005';
import a006 from './a006';
import a007 from './a007';
import a008 from './a008';
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// import presentations
import p001 from './@p';
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// import atoms used in nools
import w001 from '@feidao/web/atom/browser/call';
import w002 from '@feidao/web/atom/nools/oav/insert';
import w003 from '@feidao/web/atom/nools/oav/modify';
import w004 from '@feidao/web/atom/nools/oav/validate';
import { IFeidaoAiNools } from '@feidao/web/interfaces';
import OAV from '@feidao/web/atom/nools/oav';
////////////////////////////////////////////////////////////////////////////////

const tpls = { p001 };

function s002(fd: IFeidaoAiNools, pname: string, oav: OAV) {
	const res = tpls[pname];
	oav.v = res;
	fd.flow.modify(oav);
}

const feidao = {
	s002, w001, w002, w003, w004
};

const actions = { a003, a004, a005, a006, a007, a008 };

const rules = { a001, a002 };

export default function main(url: string, query: any) {
	return init(id, s, rules, feidao, actions, url, query, { spaceid, systemid, refsystemid });
}
